#define CATCH_CONFIG_MAIN
#include "../catch2/catch.hpp"
#include "test_header.h"

using namespace lib;

TEST_CASE("RegistererTest", "[Test]")
{
    BaseClass1 *ptr = nullptr;
    ptr = BaseClass1Registerer::GetInstanceByName("DerivedClass1");
    CHECK(ptr != nullptr);
    CHECK(ptr->Name() == "DerivedClass1");
    ptr = BaseClass1Registerer::GetInstanceByName("NotExists");
    CHECK(ptr == nullptr);
    CHECK(BaseClass1Registerer::IsValid("DerivedClass1"));
    CHECK(false == BaseClass1Registerer::IsValid("NotExists"));
    CHECK(BaseClass1Registerer::GetUniqInstanceName() == "DerivedClass1");
    BaseClass1 *ptr1 = BaseClass1Registerer::GetUniqInstance();
    CHECK(ptr1 != nullptr);

    std::vector<std::string> derived_classes;
    CHECK(true == GetRegisteredClasses("BaseClass1", &derived_classes));
    CHECK(derived_classes.size() == 1u);
    CHECK(derived_classes[0] == "DerivedClass1");

    CHECK(true == GetRegisteredClasses("BaseClass2", &derived_classes));
    CHECK(derived_classes.size() == 2u);
    CHECK(derived_classes[1] == "DerivedClass2");
};
